package com.imau.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.imau.bean.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.util.List;

public interface RoleMapper extends BaseMapper<Role> {

    /**
     * 重写父接口 为外键表多对多 一对多关联
     * @param id
     * @return
     */
    @Override
    Role selectById(Serializable id);

    List<Role> selectListByUerId(@Param("id") Serializable id);



    /**删除时维护中间表*/
    @Delete("delete  from t_user_role where role_id = #{rid} ")
    int deleteUserRoleByI(@Param("rid") Serializable rid);

    Role getRole(@Param("id") Object id);

    int addRolePrem(@Param("rid") String rid, @Param("premId") String premId);

    int updateRolePrem(@Param("rid") String rid, @Param("premId") String premId);

    @Delete("delete  from t_role_permission where role_id = #{rid}")
    int deleteRolePrem(@Param("rid") Object rid);

    @Select("select permission_id  as perid from t_role_permission where  role_id = #{rid} ")
    List<String> getRolePermList(@Param("rid") Object rid);


}
